package com.ks.user.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.ks.core.base.OperationContext;
import com.ks.core.exception.BizExceptionEnum;
import com.ks.core.exception.GunsException;
import com.ks.user.controller.dto.ApBaseRequest;
import com.ks.user.dao.DashboadBaseMapper;
import com.ks.user.entity.ApBase;
import com.ks.user.entity.DashboadBase;
import com.ks.user.entity.DashboadTenant;
import com.ks.user.dao.DashboadTenantMapper;
import com.ks.user.service.IDashboadTenantService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 看板-租户看板配置 服务实现类
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-24
 */
@Service
public class DashboadTenantServiceImpl extends ServiceImpl<DashboadTenantMapper, DashboadTenant> implements IDashboadTenantService {

    @Resource
    private  DashboadTenantMapper dashboadTenantMapper;

    @Resource
    private DashboadBaseMapper dashboadBaseMapper;

    @Override
    public Map<String, Object> selectDashboadTenant(OperationContext context, ApBaseRequest apBaseRequest) {
        DashboadTenant dashboadTenant = new DashboadTenant();
        dashboadTenant.setTenantID(context.getTenantId().intValue());
        dashboadTenant.setOrgID(context.getOrgId().intValue());
        dashboadTenant.setOrgSubID(context.getOrgSubId().intValue());
        dashboadTenant.setConfigContent(null);
        List<DashboadBase> dashboadBaseList = dashboadTenantMapper.tenantBaseRelationInfo(dashboadTenant);
        Map<String, Object>  map = new HashMap<>();
        map.put("list",dashboadBaseList);
        return map;
    }

    @Override
    public int updateDashboadTenant(OperationContext context, DashboadTenant dashboadTenant) {
        Integer i = dashboadTenantMapper.updateById(dashboadTenant);
        return i;
    }
}
